
float4x4 WVP;

float2 offXY = float2(0.0f,0.0f);

texture tbase0;

 
 float2 chunk_size = float2(64,64);

sampler sampl0 = sampler_state
{
  texture = <tbase0>;
  mipfilter = LINEAR;
};


//--------------------------------------------------------------------------------------
// Vertex shader
//--------------------------------------------------------------------------------------
struct VS_IN
{
	float3 pos	:POSITION;
};
struct VS_OUT
{
	float4 pos	:POSITION;
	float2 uv	:TEXCOORD0;
};

VS_OUT RenderVS( VS_IN In )
{
	VS_OUT Out;
	Out.uv.x = (256-In.pos.x)/256.0f;
	Out.uv.y = (256-In.pos.y)/256.0f;
	In.pos.xz += offXY.xy;
	Out.pos = mul(float4(In.pos,1), WVP); 
	return Out;
};

//------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Pixel shader
//--------------------------------------------------------------------------------------
struct PS_IN
{
	float2 uv	:TEXCOORD0;
};

float4 RenderPS( PS_IN In ) : COLOR0
{
	float4 outColor = tex2D(sampl0, In.uv);

	outColor.a = 1;
	if(outColor.r > 0.9f )
	{
	    outColor.a = 0; 
	}	
	return outColor;
}

technique FirstTechnique
{
    pass FirstPass
    {
        Lighting = TRUE;
        ZEnable = TRUE;

        VertexShader = compile vs_3_0 RenderVS();
        PixelShader =  compile ps_3_0 RenderPS();
    }
}